<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button onclick="notifyMe()">Notify me!</button>
    <script>
      function notifyMe() {
        // console.log(122);

        // var notification = new Notification("Hi there!");

        Notification.requestPermission().then(function (permission) {
          console.log(Notification.permission);

          // If the user accepts, let's create a notification
          if (permission === "granted") {
            var notification = new Notification("Hi there!", {
              body: "hahahha",
              icon: "https://www.runoob.com/images/compatible_firefox.gif",
            });
            setTimeout(() => {
              notification.close();
            }, 2000);
          }
        });
      }
    </script>
  </body>
</html>
